package termine;

import gui.DayPanel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import vars.Variables;
import xmlparse.XMLHandling;

public class Termin extends JDialog implements Variables {

	/**
	 * 
	 */
	private static final long serialVersionUID = 682574288355629328L;
	private JPanel panel, panel2;
	private JLabel label;
	private static JLabel datumsLabel;
	private static JButton buttonTermin;
	Font font, font2;
	private boolean ter;

	public Termin(final XMLHandling xmlHandling, final String dayId,
			final DayPanel dayPanel) {
		setSize(400, 150);
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				ter = true;
				setTer(true);
				dispose();
			}

		});


		setTitle("Sie haben einen Termin");
		setLocationRelativeTo(null);
		font = new Font("Papyrus", Font.BOLD + Font.ITALIC, 30);
		font2 = new Font("Rod", Font.BOLD + Font.ITALIC, 20);

		panel = new JPanel(new GridLayout(2, 1));
		panel2 = new JPanel();

		label = new JLabel("", SwingConstants.CENTER);
		datumsLabel = new JLabel("", SwingConstants.CENTER);
		datumsLabel.setFont(font2);
		datumsLabel.setForeground(sonstigeFarbe);
		buttonTermin = new JButton("Show");
		ActionListener al = new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {

				ter = true;
				xmlHandling.showIwas(dayId, dayPanel);
				dispose();
			}
		};
		buttonTermin.addActionListener(al);
		panel.add(label);
		panel.add(datumsLabel);
		panel2.add(buttonTermin);
		label.setText("Sie haben einen Termin!");
		label.setFont(font);
		label.setForeground(Color.red);

		add(panel, BorderLayout.CENTER);
		add(panel2, BorderLayout.SOUTH);

		setVisible(true);

	}

	public static void setButtonTermin(JButton buttonTermin) {
		Termin.buttonTermin = buttonTermin;
	}

	public static JButton getButtonTermin() {
		return buttonTermin;
	}

	public void setTer(boolean ter) {
		this.ter = ter;
	}

	public boolean isTer() {
		return ter;
	}

	public static void setDatumsLabel(JLabel datumsLabel) {
		Termin.datumsLabel = datumsLabel;
	}

	public static JLabel getDatumsLabel() {
		return datumsLabel;
	}

}
